package harvard.cscie160.hw7.project;
import java.util.HashMap;

/**
 * Class used to set and determine the access privileges for specific accounts.
 * @author M Bret Blackford
 *
 */
public class SecurityRecord {
	
	private String PIN; //probably not a good idea to pass around a PIN unencrypted
	private final HashMap<OperationEnumType, Boolean> permissions;

	public SecurityRecord() {
		permissions = new HashMap<OperationEnumType, Boolean>();
	}

	//probably not a good idea to pass around a PIN unencrypted
	public String getPIN() {
		return PIN;
	}

	public void setPIN(String _PIN) {
		this.PIN = _PIN;
	}

	public void setAuthorization(OperationEnumType type, boolean access) {
		permissions.put(type, access);
	}

	/**
	 * Can we do this or not?  Let's check.
	 * @param type
	 * @return
	 */
	public boolean getAuthorization(OperationEnumType type) {
		
		Boolean isAuthorized = permissions.get(type);

		/* default permission is true */
		if (isAuthorized == null) {
			isAuthorized = true;
		}

		return isAuthorized;
	}
}

